package tau.dimes.config;

import java.io.IOException;
import java.io.InputStream;

import javax.xml.parsers.ParserConfigurationException;

import org.w3c.dom.Document;
import org.xml.sax.SAXException;

import tau.dimes.util.XmlHelper;

public class XmlConfigurationSource implements ConfigurationSource
{
	private final ConfigurationNode configNode;

	public XmlConfigurationSource(InputStream is) throws ParserConfigurationException,
		SAXException, IOException
	{
		Document xmlDocument = XmlHelper.GetXmlContent(is);
		this.configNode = ConfigurationNodeBuilder.build(xmlDocument);
	}

	public ConfigurationNode getConfigurationNode(String sectionName)
	{
		return configNode.getChild(sectionName);
	}
}
